#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2014-2018, Intel Corporation
#
#
# pmempool_create/TEST6 -- test for pmempool create command with poolset
#

. ../unittest/unittest.sh

require_test_type medium

require_fs_type pmem non-pmem

setup

POOLSET=$DIR/pool.set
POOL1=$DIR/pool.part1
POOL2=$DIR/pool.part2
POOL3=$DIR/pool.part3
POOLS="$POOL1 $POOL2 $POOL3"
POOLREP=$DIR/rep.set
REPL1=$DIR/pool.rep.part1
REPL2=$DIR/pool.rep.part2
REPL3=$DIR/pool.rep.part3
REPS="$REPL1 $REPL2 $REPL3"

create_poolset $POOLSET 32M:$POOL1:z 32M:$POOL2:z 32M:$POOL3:z
check_file $POOLSET

rm -f $POOLREP
create_poolset $POOLREP 32M:$POOL1:z 32M:$POOL2:z 32M:$POOL3:z\
	R 32M:$REPL1:z 32M:$REPL2:z 32M:$REPL3:z
check_file $POOLREP

# PMEMBLK
rm -f $POOLS
expect_normal_exit $PMEMPOOL$EXESUFFIX create blk 512 $POOLSET
check_files $POOLS
check_signatures PMEMBLK $POOLS

# PMEMLOG
rm -f $POOLS
expect_normal_exit $PMEMPOOL$EXESUFFIX create log $POOLSET
check_files $POOLS
check_signatures PMEMLOG $POOLS

# PMEMOBJ
rm -f $POOLS
expect_normal_exit $PMEMPOOL$EXESUFFIX create --layout=LAYOUT_NAME$SUFFIX obj $POOLSET
check_files $POOL
check_signatures PMEMOBJ $POOLS

# PMEMOBJ with replica
rm -f $POOLS
expect_normal_exit $PMEMPOOL$EXESUFFIX create --layout=LAYOUT_NAME$SUFFIX obj $POOLREP
check_files $POOLS $REPS
check_signatures PMEMOBJ $POOLS $REPS

rm -f $POOLS
rm -f $REPS
rm -f $POOLSET
rm -f $POOLREP
pass
